{% extends 'AdminsBundle:base:main.content.submit.div.auto.html.twig' %}

{% block main %}
    {{ form_widget(show) }}
    {#Start:多图处理机制#}
    <dl>
        <dt>商品图片</dt>
        <dd>
            <a id="pics_add" class="icon-btn add" href="javascript:addPics();"><i></i><span>新增一条</span></a>
        </dd>
        <div id="pics_box">
            <div id="one_pic_first">
                <div class="line10"></div>
                <dt>
                    <a class="icon-btn del" href="javascript:delPics('#one_pic_first');"><i></i><span>删除</span></a>
                </dt>
                <dd>
                    <div>
                        <input name="picsLists[]" type="text" class="input normal upload-path" datatype="*" value="{{ picsListsFirstPic is defined ? picsListsFirstPic : "" }}">
                        <div class="upload-box upload-img"></div>
                    </div>
                </dd>
            </div>
            {% if picsLists is defined %}
                {% for url in picsLists %}
                    {% set r = random() %}
                    <div id="one_pic_{{ r }}">
                        <div class="line10"></div>
                        <dt>
                            <a class="icon-btn del" href="javascript:delPics('#one_pic_{{ r }}');"><i></i><span>删除</span></a>
                        </dt>
                        <dd>
                            <div>
                                <input name="picsLists[]" type="text" class="input normal upload-path" datatype="*" value="{{ url }}">
                                <div class="upload-box upload-img"></div>
                            </div>
                        </dd>
                    </div>
                {% endfor %}
            {% endif %}
        </div>
        <script type="text/javascript">
            function addPics() {
                var rnd = parseInt(Math.random()*100000);
                var html = '' +
                        '<div id="one_pic_' + rnd + '">' +
                        '<div class="line10"></div>'+
                        '<dt>' +
                        '<a class="icon-btn del" href="javascript:delPics(\'#one_pic_'+rnd+'\');"><i></i><span>删除</span></a>'+
                        '</dt>' +
                        '<dd>'+
                        '<div>'+
                        '<input name="picsLists[]" type="text" class="input normal upload-path" datatype="*">'+
                        '<div class="upload-box upload-img"></div>'+
                        '</div>'+
                        '</dd>'+
                        '</div>';
                $("#pics_box").append(html);
                //初始化上传控件
                $("#one_pic_"+ rnd +" .upload-img").each(function () {
                    $(this).InitSWFUpload({
                        button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,
                        sendurl: "/nbupload/swf_upload.r?nbdir=product",
                        flashurl: "/assets/js/swfupload/swfupload.swf",
                        filetypes: "*.gif;*.jpg;*.png;*.bmp;"
                    });
                });
            }
            function delPics(me) {
                $(me).remove();
            }
        </script>
    </dl>
    {#end:  多图处理机制#}


{% endblock %}
{% block script %}
    {% include 'AdminsBundle:base:inc.js.product.upload.twig' %}
    {% include 'AdminsBundle:base:inc.js.article.twig' %}
    {% include 'AdminsBundle:base:inc.js.form.valid.twig' %}
    {% include 'AdminsBundle:base:inc.js.date.picker.twig' %}
{% endblock %}

